package com.sdap2.common.context;

import com.sdap2.entity.SysUser;
import lombok.experimental.UtilityClass;

@UtilityClass
public class RequestContext {
    private static final ThreadLocal<SysUser> userHolder = new ThreadLocal<>();
    private static final ThreadLocal<String> requestIdHolder = new ThreadLocal<>();

    public static void setCurrentUser(SysUser user) {
        userHolder.set(user);
    }

    public static SysUser getCurrentUser() {
        return userHolder.get();
    }

    public static void setRequestId(String requestId) {
        requestIdHolder.set(requestId);
    }

    public static String getRequestId() {
        return requestIdHolder.get();
    }

    public static void clear() {
        userHolder.remove();
        requestIdHolder.remove();
    }
} 